﻿using Castle.ActiveRecord;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Online_Course.Domain
{
    [ActiveRecord]
    public class Student:BaseEntity<Student>
    {
        [Property(Length = 30, NotNull = false)]
        [Display(Name = "姓名")]
        public string Name { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "学号")]
        public string Code { get; set; }

        //[Property(Length = 30, NotNull = false)]
        //[Display(Name = "班级")]
        //public string Class { get; set; }

        //[BelongsTo(Column = "MajorID",Cascade=CascadeEnum.None,Lazy=FetchWhen.OnInvoke)]
        //[Display(Name = "专业")]
        //public Major Major { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "电话")]
        public string Phone { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "状态")]
        public int IsActive { get; set; }

        /// <summary>
        /// 学生选课
        /// </summary>
        [HasAndBelongsToMany(typeof(Course), Table = "Student_Course", ColumnKey = "StudentId", ColumnRef = "CourseId", Cascade = ManyRelationCascadeEnum.None, Lazy = false)]
        [Display(Name = "学生选课表")]
        public IList<Course> CourseList { get; set; } 
    }
}
